﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ConsoleApplication2.Models;

namespace ConsoleApplication2.Controllers
{
    public class sc_roomController : Controller
    {
        private HMS909Context db = new HMS909Context();

        //
        // GET: /sc_room/

        public ActionResult Index()
        {
            return View(db.sc_room.ToList());
        }

        //
        // GET: /sc_room/Details/5

        public ActionResult Details(double id = 0.0)
        {
            sc_room sc_room = db.sc_room.Find(id);
            if (sc_room == null)
            {
                return HttpNotFound();
            }
            return View(sc_room);
        }

        //
        // GET: /sc_room/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /sc_room/Create

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create(sc_room sc_room)
        {
            if (ModelState.IsValid)
            {
                db.sc_room.Add(sc_room);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(sc_room);
        }

        //
        // GET: /sc_room/Edit/5

        public ActionResult Edit(double id = 0.0)
        {
            sc_room sc_room = db.sc_room.Find(id);
            if (sc_room == null)
            {
                return HttpNotFound();
            }
            return View(sc_room);
        }

        //
        // POST: /sc_room/Edit/5

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit(sc_room sc_room)
        {
            if (ModelState.IsValid)
            {
                db.Entry(sc_room).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(sc_room);
        }

        //
        // GET: /sc_room/Delete/5

        public ActionResult Delete(double id = 0.0)
        {
            sc_room sc_room = db.sc_room.Find(id);
            if (sc_room == null)
            {
                return HttpNotFound();
            }
            return View(sc_room);
        }

        //
        // POST: /sc_room/Delete/5

        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(double id)
        {
            sc_room sc_room = db.sc_room.Find(id);
            db.sc_room.Remove(sc_room);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}